import Vue from 'vue'
import axios from 'axios'
import {request} from '@/core/ajax'

Vue.prototype.$http = axios
axios.defaults.baseURL = '/api'
// axios.defaults.xsrfHeaderName = 'X-CSRFToken'
// axios.defaults.xsrfCookieName = 'csrftoken'


export default {
  login (username, password) {
    return request("login", "POST", {
      data: {
        username,
        password
      }
    })
  },
  logout () {
    return request("logout", "GET", {})
  },
  getProfile () {
    return request("profile", "GET", {})
  },
  getArticleList (params) {
    return request("admin/article", "GET", {params})
  },
  getArticle (id) {
    let url = "admin/article/" + id
    return request(url, "GET", {})
  },
}
